package com.cnfilm.web.website;

import java.util.HashMap;
import java.util.List;

import com.cnfilm.utils.CacheManager;
import com.jfinal.plugin.activerecord.Model;

/**
 * Video model.
 */
@SuppressWarnings("serial")
public class Website extends Model<Website> {
	
	public static final Website dao = new Website();
	
	@SuppressWarnings("unchecked")
	public static HashMap<String,String> getConfig(){
		String key = "cache_getConfig";
		HashMap<String,String> map =  null;
		List<Website> websiteList = null;
		boolean hasCache = CacheManager.hasCache(key);
		if (hasCache) {
			map = (HashMap<String,String>)CacheManager.getCache(key);
	    } else {
	    	String sql = "select * from website";
	        websiteList = Website.dao.find(sql);
	    	map = new HashMap<String,String>();
			for(Website web:websiteList){
				map.put(web.getStr("code"), web.getStr("content"));
			}
		    CacheManager.putCache(key, map);  
	    }
		return map;
	}
}